Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: local-orch-account .transfer() supports pfm routes #10571

Merged
merged 19 commits into from
Dec 4, 2024

Conversation

0xpatrickdev
Copy link
Member

@0xpatrickdev 0xpatrickdev commented Nov 26, 2024

refs: #10445

Description

  • leverages ChainHub.makeTransferRoute to support PFM routing in LocalOrchAccount.transfer()
  • updates test harness to supply chain and asset info for chainHub in exo and contract tests
  • refactors send-anywhere contract-upgrade.test.ts to no longer rely on a buggy agoricNames
  • updates several orchestration examples contracts to seed their own chainHub to facilitate boot and multichain testing

Security Considerations

No new considerations from these changes.

Scaling Considerations

No new considerations from these changes.

Documentation Considerations

None

Testing Considerations

Includes unit tests. See #10584 for more robust testing of the pfm route logic. Existing multichain-testing will cover potential regressions (single-hop) transfers. Multi-hop tests are forthcoming.

Upgrade Considerations

N/A, library code. Part of NPM Orch or FUSDC release.

Copy link

cloudflare-workers-and-pages bot commented Nov 26, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: a2d491f
Status: ✅  Deploy successful!
Preview URL: https://c2569010.agoric-sdk.pages.dev
Branch Preview URL: https://pc-10445-transfer-pfm.agoric-sdk.pages.dev

View logs

Base automatically changed from 10006-transfer-pfm to master November 26, 2024 17:06
Copy link

Base branch is changed to master. Please re-run the integration tests by adding 'force:integration' label.

@0xpatrickdev 0xpatrickdev force-pushed the pc/10445-transfer-pfm branch 2 times, most recently from 5977597 to 9c0a243 Compare November 28, 2024 03:02
@0xpatrickdev 0xpatrickdev added the force:integration Force integration tests to run on PR label Nov 28, 2024
@0xpatrickdev 0xpatrickdev marked this pull request as ready for review November 28, 2024 04:44
@0xpatrickdev 0xpatrickdev requested a review from a team as a code owner November 28, 2024 04:44
@0xpatrickdev 0xpatrickdev marked this pull request as draft November 29, 2024 04:31
@0xpatrickdev 0xpatrickdev changed the base branch from master to pc/10445-chain-hub-get-asset November 29, 2024 23:45
@0xpatrickdev 0xpatrickdev marked this pull request as ready for review November 30, 2024 01:04
@0xpatrickdev
Copy link
Member Author

This is now dependent on #10588.

As of writing I see green minus some seemingly unrelated inter integration tests.

Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks pretty good

If any of my comments turn out to be important, I'm confident that we can address them in due course.

),
const { forwardOpts, ...rest } = opts ?? {};

// throws if route is not determinable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hoist that to a @throws on the transfer method?

@@ -686,12 +682,16 @@ export const prepareLocalOrchestrationAccountKit = (
transfer(destination, amount, opts) {
return asVow(() => {
trace('Transferring funds from LCA over IBC');
const denomAmount = coerceDenomAmount(chainHub, amount);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can throw, right? Add a @throws in the transfer docstring in orchestration-api.ts?

I see TODO document the mapping from the address to the destination chain.

Is it time to document that now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated here and orchestration-api.ts

Comment on lines 197 to 204
{ message: /connection not found: agoric-3<->fakenet/ },
{ message: 'no connection info found for "agoric-3_fakenet"' },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kinda like <->. I wonder why it went away.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restored

Comment on lines -18 to +16
* @returns {[string, DenomDetail & { brandKey?: string }]}
* @returns {[string, DenomDetail]}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

assetOn('ubld', 'agoric', bldSansMint.brand),
assetOn('uist', 'agoric', istSansMint.brand),
assetOn('uusdc', 'noble', undefined, 'agoric', chainInfoWithCaps),
assetOn('uatom', 'cosmoshub', undefined, 'agoric', chainInfoWithCaps),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no ATOM brand? that's a little odd.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have one created in test support yet. I guess no tests currently call for it.

Comment on lines 344 to 345
console.warn(
'⚠️ `amountToCoin` not working until #10449; use `DenomAmount` for now',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm. "death before confusion" suggests throwing here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to throw here. Had to refactor the staking-combinations example contract a bit as a result

@@ -67,6 +71,13 @@ const contract = async (

const creatorFacet = prepareChainHubAdmin(zone, chainHub);

registerChainsAndAssets(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about the way each "feat" shows up in release notes, I wonder if "feat: auto-stake-it provides its own chain, connection, asset info" would make a better commit message.

Or, since auto-stake-it is more of an example than an orch API product feature, call it a chore.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good feedback, updated

Comment on lines +42 to +50
'--assetInfo',
JSON.stringify([
[
'uist',
{
baseDenom: 'uist',
baseName: 'agoric',
chainName: 'agoric',
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no IST brand. hm. I guess this test doesn't need it?

toExternalConfig would work nicely here instead of JSON.stringify. Just like...

options: toExternalConfig(config, crossVatContext, FastUSDCConfigShape),

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toExternalConfig would work nicely here instead of JSON.stringify. Just like...

Agree, but I did not tackle this here. Something to improve in the future.

startUpgradable,
},
installation: {
// @ts-expect-error not a WellKnownName
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

elsewhere we refine the powers type to tell callers what's really expected

@@ -652,17 +656,24 @@ const makeCustomer = (
{ amount: String(toReceive.value), denom: uusdcOnAgoric },
'C4',
);

t.log(who, 'sees', ibcTransferMsg.token, 'sent to', EUD);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any particular reason to get rid of this t.log()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, restored

Copy link

github-actions bot commented Dec 3, 2024

Base branch is changed to master. Please re-run the integration tests by adding 'force:integration' label.

@0xpatrickdev 0xpatrickdev removed the force:integration Force integration tests to run on PR label Dec 3, 2024
@0xpatrickdev
Copy link
Member Author

@mergify refresh

Copy link
Contributor

mergify bot commented Dec 3, 2024

refresh

✅ Pull request refreshed

@0xpatrickdev 0xpatrickdev force-pushed the pc/10445-transfer-pfm branch from a1132f4 to a706d28 Compare December 3, 2024 22:34
@0xpatrickdev
Copy link
Member Author

@mergify queue

Copy link
Contributor

mergify bot commented Dec 3, 2024

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at 9b8cad2

0xpatrickdev and others added 19 commits December 3, 2024 23:42
- shape used for pfm ForwardInfo options
- provide `chainInfo` and `assetInfo` in commonPrivateArgs for contracts to use
- register common assets used in testing
- provide `populateChainHub` function for use in exo unit testing in favor of `registerAgoricBld`
this test can no longer rely on the IST brand being available, so we
 - added checks to ensure brands are accepted for `.transfer` and `.send`. marked as failing for now
 - filed #10449 since this surfaced a bug in `amountToCoin`
 - use Moolah issuer for "no denom for brand" failure path tests
- enables sending offers with brands
- chainInfo and assetInfo are provided as `commonPrivateArgs`. include them in `ContractMeta`
- auto-stake-it initializes `chainHub` with data so existing tests that use `.transfer()` pass
- no longer needed since we call `registerChainsAndAssets`
- no longer relies on buggy agoricNames
- continues to test async-flow resumability and cross-chain vow settlement across upgrade

Co-authored-by: 0xPatrick <[email protected]>
- test/bootstrapTests/orchestration.test.ts used a mixed of test and test.serial
- the test without `.serial` interleaved and was confusing to debug
- this mainly updates inline snapshots, which return different account and channel
  identifiers since all tests in this file share the same context
- basic-flows.contract.js is provided with `chainInfo` and `assetInfo` in `privateArgs` via builder options
- needed for tests that use `localAccount.transfer()`, now reliant on asset info, to pass
@0xpatrickdev 0xpatrickdev force-pushed the pc/10445-transfer-pfm branch from a706d28 to a2d491f Compare December 3, 2024 23:43
@mergify mergify bot merged commit 9b8cad2 into master Dec 4, 2024
81 checks passed
@mergify mergify bot deleted the pc/10445-transfer-pfm branch December 4, 2024 00:27
mergify bot added a commit that referenced this pull request Dec 4, 2024
closes: #9966
closes: #10445

## Description
Adds multi-hop (PFM) scenarios to the `examples/send-anywhere.contract.js` multichain (e2e) test.  To support this change, this PR also includes:
  - a proposal for registering interchain assets in vbank (closes #9966). aims for production quality but is only used in tests 
  - a `fundFaucet` helper in `multichain-testing` so developers can request ATOM, OSMO, etc in `provisionSmartWallet`
  - a `GoDuration` type in `@agoric/orchestration` that captures basic Go [time duration strings](https://pkg.go.dev/time#ParseDuration) and an update to `DefaultPfmTimeoutOpts` (10min -> 10m)


### Security Considerations

`@agoric/builders/scripts/testing/register-interchain-bank-assets.js` allows callers overwrite assets in `vbank` and `agoricNames`. It's only intended for testing, and shouldn't be used in production. A production version might guard against accidental overrides.

### Scaling Considerations
None, mostly test code. Adds a little CI time to `multichain-testing` for the extra CoreEval.

### Documentation Considerations
None

### Testing Considerations
Includes an E2E to test in `multichain-testing` that leverages `register-interchain-bank-assets.js`. Also includes the first E2E test of PFM functionality added in #10584 and #10571.

### Upgrade Considerations
None, library code an NPM orch or FUSDC release.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:rebase Automatically rebase updates, then merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants